/// @file PatternManager.h
#pragma once

#include <QPolygonF>
#include <QFileDialog>
#include <QObject>
#include <core/Tan.h>
#include <QFile>
#include <QDataStream>
#include <QLinkedList>
#include <QMessageBox>

namespace qtangram {
    /**
      @class PatternManager
      @brief handles reading and writing patterns
      */
    class PatternManager : public QObject {
	Q_OBJECT
    public:
	/// @brief Default constructor
	PatternManager(QWidget* parent = 0, float min = -1, float max = 1) : QObject(parent), min(min), max(max), magicNr(0xDEFEC8ED + 2) {}
	/**
	@brief Opens file dialog window and loads pattern from pointed file.
	Emits patternLoaded(QLinkedList<Tan>) signal
	*/
	void load();
	void save(const QLinkedList<Tan>& tans); ///< @brief Carries out binary writing pattern.
    signals:
	void patternLoaded(QLinkedList<Tan> newPattern); ///< @brief Signal that is emitted when new pattern has been read.
    private:
	float min, max;
	const quint64 magicNr;
    };
}
